<template>
    <div class="boxcontent">
        <div class="shopcartTop">
            <p>购物车</p>
            <span @click="clearFn">清空</span>
        </div>
        <div class="shopcartContent">
            <ul>
                <li v-for="(item,index) in list" :key="index">
                    <p>{{item.name}}</p>
                    <div class="rightBar">
                        <span>￥ {{item.price*item.num}}</span>
                        <i @click="reduceFn(item)" class="iconfont icon-jianshao"></i>
                        <i class="textbar">{{item.num}}</i>
                        <i @click="addFn(item)" class="iconfont icon-tianjia1"></i>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
export default {
    name:"shopcar",
    props:["list"],
    methods:{
        clearFn(){
            this.$bus.$emit("clearFn")
        },
        addFn(item){
            this.$bus.$emit("addFn",item)
        },
        reduceFn(item){
            this.$bus.$emit("reduceFn",item)
            console.log(this.list.length, item.num)
        }
    }
}
</script>

<style lang="less" scope>
.boxcontent{
    position: fixed;
    left:0;
    bottom: 0.9rem;
    right:0;
    z-index: 9;
    .shopcartTop{
    height:0.8rem;
    padding: 0 0.36rem;
    display:flex;
    justify-content:space-between;
    background-color:#f3f5f7;
    border-bottom:0.01rem solid rgba(7,17,27,0.1);
    p{
        font-size: 0.28rem;
        font-weight: 500;
        color:rgb(7, 17, 27);
        line-height: 0.8rem;
    }
    span{
        font-size: 0.24rem;
        color: rgb(0, 160, 220);
        line-height: 0.8rem;
    }
}
    .shopcartContent{
        padding: 0 0.36rem;
        background-color:#fff;
        ul{
            li{
                border-bottom:0.01rem solid rgba(7,17,27,0.1);
                display:flex;
                align-items: center;
                justify-content:space-between;
                padding: 0.24rem 0;
                p{
                    font-size: 0.28rem;
                    color: rgb(7, 17, 27);
                    line-height: 0.48rem;
                }
                .rightBar{
                    display:flex;
                    align-items:center;
                    span{
                        font-size: 0.3rem;
                        font-weight: normal;
                        color: rgb(240, 20, 20);
                        line-height: 0.48rem;
                        margin-left: 0.36rem;
                    }
                    .iconfont{
                        font-size: 0.48rem;
                        color: rgb(32, 133, 235);
                        line-height: 0.48rem;
                        &.icon-jian{
                            margin-left: 0.24rem;
                        }
                    }
                    .textbar{
                        font-size: 0.2rem;
                        color: rgb(147,153,159);
                        line-height: 0.48rem;
                        margin: 0 0.24rem;
                    }
                }
            }
        }
    }
}


</style>